//
// Created by hjie on 23-9-3.
//

#pragma once

#include <string>
#include <cstring>
#include <memory>
#include <functional>
#include <map>
#include <vector>
#include <rapidjson/document.h>
#include "base_protocol.h"

class PublishReqProtocol : public BaseProtocol
{
public:
    PublishReqProtocol();
    virtual bool ParseData(rapidjson::Document & input) override;
public:
    std::string m_user_id;
    std::string m_sdp_type;
    std::string m_sdp_info;
};

class PublishResProtocol : public BaseProtocol
{
public:
    PublishResProtocol();
    virtual void Dump(rapidjson::Document & output) override;
public:

};

class PublishTargetProtocol : public BaseProtocol
{
public:
    PublishTargetProtocol();
public:
    virtual void Dump(rapidjson::Document & output) override;
public:
    std::string m_from_user_id;
    std::string m_sdp_type;
    std::string m_sdp_info;
};
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

class SubscribeReqProtocol : public BaseProtocol
{
public:
    SubscribeReqProtocol();
    virtual bool ParseData(rapidjson::Document & input) override;
public:
    std::string m_subscribe_user_id;
};

class SubscribeResProtocol : public BaseProtocol
{
public:
    SubscribeResProtocol();
    virtual void Dump(rapidjson::Document & output) override;
public:
    
};

class SubscribeTargetProtocol : public BaseProtocol
{
public:
    SubscribeTargetProtocol();
    virtual void Dump(rapidjson::Document & output) override;
public:
    std::string m_subscribe_user_id;
};


////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class PublishStreamReqProtocol : public BaseProtocol
{
public:
    PublishStreamReqProtocol();
    virtual bool ParseData(rapidjson::Document & input) override;
public:
    bool m_status;
};

class PublishStreamResProtocol : public BaseProtocol
{
public:
    PublishStreamResProtocol();
    virtual void Dump(rapidjson::Document & output) override;
public:

};

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class GetPublishStreamStatusReqProtocol : public BaseProtocol
{
public:
    GetPublishStreamStatusReqProtocol();
    virtual bool ParseData(rapidjson::Document & input) override;
public:
    std::string m_user_id;
};

class GetPublishStreamStatusResProtocol : public BaseProtocol
{
public:
    GetPublishStreamStatusResProtocol();
    virtual void Dump(rapidjson::Document & output) override;
public:
    std::string m_user_id;
    bool m_publish_status;
};

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

class SendAnswerReqProtocol : public BaseProtocol
{
public:
    SendAnswerReqProtocol();
    virtual bool ParseData(rapidjson::Document & input) override;
public:
    std::string m_user_id;
    std::string m_sdp;
    std::string m_type;
};

class SendAnswerResProtocol : public BaseProtocol
{
public:

};

class SendAnswerTargetProtocol : public BaseProtocol
{
public:
    SendAnswerTargetProtocol();
    virtual void Dump(rapidjson::Document & output) override;
public:
    std::string m_user_id;
    std::string m_sdp;
    std::string m_type;
};

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

/*
 *
 * {
    "header":{
        "msg_type":"ice_candidate_req",
        "room_id":"1111",
        "user_id":"22"
    },
    "content":{
        "candidate":{
            "candidate":"candidate:3794970868 1 tcp 1518280447 172.17.0.1 9 typ host tcptype active generation 0 ufrag 8fCW network-id 1",
            "sdpMid":"0",
            "sdpMLineIndex":0,
            "usernameFragment":"8fCW"
        },
        "user_id":"11",
        "sdp_type":"offer,answer"
    }
}
 */

struct Candidate
{
    std::string m_candidate;
    std::string m_sdp_mid;
    int m_sdp_m_line_index;
    std::string m_username_fragment;
};

class IceCandidateReqProtocol : public BaseProtocol
{
public:
    IceCandidateReqProtocol();
    virtual bool ParseData(rapidjson::Document & input) override;
public:
    std::string m_user_id;
    Candidate m_candidate;
    std::string m_sdp_type;
};

class IceCandidateTargetProtocol : public BaseProtocol
{
public:
    IceCandidateTargetProtocol();
    virtual void Dump(rapidjson::Document & output) override;
public:
    std::string m_user_id;
    Candidate m_candidate;
    std::string m_sdp_type;
};
